package com.lx.chong;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import java.util.concurrent.CountDownLatch;

@Slf4j
@EnableCaching
@SpringBootApplication
public class LxApiApplication extends SpringBootServletInitializer {


    @Bean
    CountDownLatch latch() {
        return new CountDownLatch(1);
    }

    @Bean
    public ObjectMapper ObjectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper;
    }


    public static void main(String[] args) throws InterruptedException {
        ApplicationContext context = SpringApplication.run(LxApiApplication.class, args);
        CountDownLatch latch = context.getBean(CountDownLatch.class);
        log.info("[Redis订阅开启],频道:{}");
        latch.await();
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(LxApiApplication.class);
    }

}
